<html>
<head>
 
</head>
<body style="text-align=center;font-size:32px;">
<table align="center">
<tr><td><div id="problemNum" style='background-color:#999999;width:800;text-align:center;font-size:32px;'></div></td></tr>
<tr><td><div id="problemContent" style='word-wrap:break-word;background-color:#bbbbbb;width:800;text-align:left;font-size:Npx;'></div></td></tr>
<tr><td><div id="sum" style='word-wrap:break-word; color:#ffff22;font-size:48;background-color:#8855ff;width:800;text-align:center;'></div></td></tr>
<tr><td><div id="copyleft" style='word-wrap:break-word; color:#ffff22;font-size:18;background-color:#666666;width:800;text-align:right;'></div></td></tr>
<script language="javascript">
    //---------------------------------//
    // Project Euler 
    //
    // Author:thrombin
    //   Date:2015-12-19
    //---------------------------------//  
var p_order=20;//Problem Order
 
var problem='n! means n x (n - 1) x ... x 3 x 2 x 1<br/>\
For example, 10! = 10 x 9 x ... x 3 x 2 x 1 = 3628800,<br/>\
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.<br/>\
Find the sum of the digits in the number 100!';
 
 
//solve the problem
//==============编程思路简介================
//  用数组存储n的阶乘的每一位，
//      通过动态规划来逐步求100的阶乘
//=========================================
var fact=[4,2];
 
for(var n=5;n<101;n++){
    var jin_wei=0;
    for(var j=0;j<fact.length;j++){
        var tmp=fact[j]*n+jin_wei;
        fact[j]=tmp%10;
        jin_wei=parseInt(tmp/10);
    }
    while(jin_wei>0){
        fact.push(jin_wei%10);
        jin_wei=parseInt(jin_wei/10);
    }
}
var sum=0;//存储100！的所有数字之和
for(var i=0;i<fact.length;i++)sum+=fact[i];
//update browser
document.getElementById("problemNum").innerHTML="Project Euler-Problem "+p_order;
document.getElementById("problemContent").innerHTML=problem;
document.getElementById("sum").innerHTML="Answer:"+sum;
document.getElementById("copyleft").innerHTML="CopyLeft@Thrombin 2015";
</script>
</body>
</html>